package Sudoku;

import Sudoku.Sudoku;
import junit.framework.JUnit4TestAdapter;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;


public class test {
	
	
	
	final static int[][] fullField = new int[][] { { 5, 3, 4, 6, 7, 8, 9, 1, 2 },
			{ 6, 7, 2, 1, 9, 5, 3, 4, 8 }, { 1, 9, 8, 3, 4, 2, 5, 6, 7 },
			{ 8, 5, 9, 7, 6, 1, 4, 2, 3 }, { 4, 2, 6, 8, 6, 3, 7, 9, 1 },
			{ 7, 1, 3, 9, 2, 4, 8, 5, 6 }, { 9, 6, 1, 4, 3, 7, 2, 8, 4 },
			{ 2, 8, 7, 4, 1, 9, 6, 3, 5 }, { 3, 4, 5, 2, 8, 6, 1, 7, 4 } };

	final static int[][] actualField1 = new int[][] {
			{ 5, 3, 0, 0, 7, 0, 0, 0, 0 }, { 6, 0, 0, 1, 9, 5, 0, 0, 0 },
			{ 0, 9, 8, 0, 0, 0, 0, 6, 0 }, { 8, 0, 0, 0, 6, 0, 0, 0, 3 },
			{ 4, 0, 0, 8, 0, 3, 0, 0, 1 }, { 7, 0, 0, 0, 2, 0, 0, 0, 6 },
			{ 0, 6, 0, 0, 0, 0, 2, 8, 0 }, { 0, 0, 0, 4, 1, 9, 0, 0, 5 },
			{ 0, 0, 0, 0, 8, 0, 0, 7, 9 } };

	final static int[][] actualField2 = new int[][] {
			{ 1, 0, 2, 0, 0, 0, 0, 0, 0 }, { 0, 0, 3, 0, 0, 0, 0, 0, 0 },
			{ 0, 0, 0, 0, 0, 0, 0, 0, 4 }, { 0, 4, 0, 0, 5, 0, 0, 0, 0 },
			{ 0, 6, 0, 0, 7, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 2, 0 },
			{ 0, 8, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 },
			{ 0, 0, 0, 0, 0, 0, 8, 0, 0 } };
	
	public static int getNextFreeField(int[][] matrix){
		int n=0;
			for(int p=0; p<9;p++){
		    for(int q=0;q<9;q++){
		    	 n++;
		    	 if (matrix[p][q]==0){return n;}
//		    	 if(p==8 && q==8 && matrix [p][q]!=0) {n= -1; return n;}
		      
		    }}
	  return -1;
	}
//	public static int getNextFreeField(int[][] conf) {
//		for(int i = 0; i<9;i++) {
//			for(int j = 0; j<9;j++) {
//				if(conf[j][i] == 0) {
//					return 9*i+j;
//				}
//			}
//		}
//		return -1;
//	}
	public static void main(String[] args) {
	
	
	System.out.println(getNextFreeField(fullField));
	System.out.println(getNextFreeField(actualField1));
	System.out.println(getNextFreeField(actualField2));
   
}}
